import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
    { // 登录页
        path: "/",
        name: "root",
        redirect: "/login",
        component: () => import('@/pages/login/Login.vue'), // 按需引入,
        children: []
    },
    { // 登录页
        path: '/login',
        name: 'login',
        component: () => import('@/pages/login/Login.vue') // 按需引入
    },
    { // 登录页
        path: '/home',
        name: '首页',
        component: () => import('@/pages/home/Home.vue'), // 按需引入
        children: [
            // Logo // 要放在Home里，要不路由会直接跳转
            {
                path: '/logo',
                name: '徽标',
                component: () => import('@/components/Logo.vue'),
                children: []
            }
        ]
    },
    {   // 主页
        path: '/index',
        name: 'index',
        component: () => import('@/pages/index/index.vue'),
        redirect: "/userpage",
        // 二级路由
        children: [
            { // 用户列表
                path: "/userpage",
                name: "userpage",
                component: () => import('@/pages/user-page/user.vue')
            }
        ]
    },


]

const router = createRouter({
    history: createWebHashHistory(), // createWebHashHistory 路径加#号
    // history: createWebHistory(),
    routes
})


export default router;